﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:controls="clr-namespace:Rhiannon.Windows.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Font.xaml"/>
        <ResourceDictionary Source="Color.xaml"/>
        <ResourceDictionary>

			<Style x:Key="ToggleBoxToggleButtonStyle" TargetType="ToggleButton">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="ToggleButton">
							<Border Name="Border">
								<Path x:Name="Arrow" Fill="#FFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 8 8 L 16 0 Z"/>
							</Border>
							<ControlTemplate.Triggers>
								<Trigger Property="ToggleButton.IsMouseOver" Value="true">
									<Setter TargetName="Border" Property="Background" Value="{StaticResource PrimaryComboBoxHoverBackgroundBrush}" />
									<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PrimaryComboBoxHoverBorderBrush}" />
								</Trigger>
								<Trigger Property="ToggleButton.IsChecked" Value="true">
									<Setter TargetName="Arrow" Property="Data" Value="M 0 0 L 8 8 L 16 0 Z" />
								</Trigger>
								<Trigger Property="IsEnabled" Value="False">
									<Setter TargetName="Arrow" Property="Fill" Value="{StaticResource PrimaryComboBoxDisabledForegroundBrush}" />
								</Trigger>
							</ControlTemplate.Triggers>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>

			<!--<ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
				<Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />
			</ControlTemplate>-->

			<Style x:Key="ToggleBoxItemStyle" TargetType="ComboBoxItem">
				<Setter Property="SnapsToDevicePixels" Value="true"/>
				<Setter Property="OverridesDefaultStyle" Value="true"/>
				<Setter Property="Height" Value="25" />
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="ComboBoxItem">
							<Border Name="Border" Padding="3" SnapsToDevicePixels="true" Margin="1">
								<ContentPresenter />
							</Border>
							<ControlTemplate.Triggers>
								<Trigger Property="IsHighlighted" Value="true">
									<Setter TargetName="Border" Property="Background" Value="{StaticResource PrimaryComboBoxHoverBackgroundBrush}" />
								</Trigger>
								<Trigger Property="IsEnabled" Value="false">
									<Setter TargetName="Border" Property="TextBlock.Foreground" Value="{StaticResource PrimaryComboBoxDisabledForegroundBrush}" />
								</Trigger>
							</ControlTemplate.Triggers>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>

			<Style x:Key="{x:Type controls:ToggleBox}" TargetType="{x:Type controls:ToggleBox}">
				<Setter Property="SnapsToDevicePixels" Value="true"/>
				<Setter Property="OverridesDefaultStyle" Value="true"/>
				<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
				<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
				<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
				<Setter Property="ItemContainerStyle" Value="{StaticResource ToggleBoxItemStyle}" />
				<Setter Property="MinWidth" Value="120"/>
				<Setter Property="Height" Value="23"/>
				<Setter Property="Margin" Value="2" />
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type controls:ToggleBox}">
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*" />
									<ColumnDefinition Width="Auto" />
								</Grid.ColumnDefinitions>
								<ToggleButton Name="ArrowToggleButton" Style="{StaticResource ToggleBoxToggleButtonStyle}" Grid.Column="1" Focusable="false"
											  IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />
								<ToggleButton Name="ContentSite" TextBlock.Foreground="{StaticResource PrimaryComboBoxNormalForegroundBrush}"
											  Grid.Column="0" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}"
											  ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
											  VerticalAlignment="Center" HorizontalAlignment="Left" />
								<Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" 
									   AllowsTransparency="True" Focusable="False" PopupAnimation="Slide" Grid.ColumnSpan="2">
									<Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
										<Border x:Name="DropDownBorder" Background="{StaticResource PrimaryComboBoxNormalPanelBackgroundBrush}" BorderThickness="1,0,1,1" BorderBrush="{StaticResource PrimaryComboBoxNormalBorderBrush}"/>
										<ScrollViewer Margin="0" SnapsToDevicePixels="True">
											<StackPanel TextBlock.Foreground="{StaticResource PrimaryComboBoxNormalForegroundBrush}" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
										</ScrollViewer>
									</Grid>
								</Popup>
							</Grid>
							<ControlTemplate.Triggers>
								<Trigger Property="HasItems" Value="false">
									<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
								</Trigger>
								<Trigger Property="IsEnabled" Value="false">
									<Setter Property="Foreground" Value="{StaticResource PrimaryComboBoxDisabledForegroundBrush}"/>
								</Trigger>
								<Trigger Property="IsGrouping" Value="true">
									<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
								</Trigger>
								<Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
									<Setter TargetName="DropDownBorder" Property="Margin" Value="0,0,0,0"/>
								</Trigger>
							</ControlTemplate.Triggers>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
				<Style.Triggers>
				</Style.Triggers>
			</Style>

		</ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>